﻿using System;
using EPiServer.Core;
using EPiServer.DataAbstraction;
using EPiServer.SpecializedProperties;
using PageTypeBuilder;
using TemplateFoundation.Tabs;

namespace TemplateFoundation.PageTypes
{
    /// <summary>
    /// Base class for start pages
    /// </summary>
    public abstract class StartPageBase : PageTypeBase, ISiteSettingsPage
    {
        #region Site contact details

        /// <summary>
        /// Gets or sets the company name
        /// </summary>
        /// <remarks>Sort order: 50</remarks>
        [PageTypeProperty(
            EditCaption = "Our company name",
            HelpText = "Our company name, commonly appended to page titles",
            DisplayInEditMode = true,
            Required = false,
            Searchable = false,
            UniqueValuePerLanguage = true,
            SortOrder = 50,
            Tab = typeof(ContactDetailsTab),
            Type = typeof(PropertyString))]
        public virtual string CompanyName { get; set; }

        /// <summary>
        /// Gets or sets the company phone number
        /// </summary>
        /// <remarks>Sort order: 100</remarks>
        [PageTypeProperty(
            EditCaption = "Our phone number",
            HelpText = "Our own phone number, commonly displayed in headers or on contact pages",
            DisplayInEditMode = true,
            Required = false,
            Searchable = false,
            UniqueValuePerLanguage = true,
            SortOrder = 100,
            Tab = typeof(ContactDetailsTab),
            Type = typeof(PropertyString))]
        public virtual string CompanyPhoneNumber { get; set; }

        /// <summary>
        /// Gets or sets the company fax number
        /// </summary>
        /// <remarks>Sort order: 110</remarks>
        [PageTypeProperty(
            EditCaption = "Our fax number",
            HelpText = "Our own fax number, commonly displayed in headers or on contact pages",
            DisplayInEditMode = true,
            Required = false,
            Searchable = false,
            UniqueValuePerLanguage = true,
            SortOrder = 110,
            Tab = typeof(ContactDetailsTab),
            Type = typeof(PropertyString))]
        public virtual string CompanyFaxNumber { get; set; }

        /// <summary>
        /// Gets or sets the company street address
        /// </summary>
        /// <remarks>Sort order: 300</remarks>
        [PageTypeProperty(
            EditCaption = "Our street address",
            HelpText = "Our own street address, commonly displayed in headers or on contact pages",
            DisplayInEditMode = true,
            Required = false,
            Searchable = false,
            UniqueValuePerLanguage = true,
            SortOrder = 300,
            Tab = typeof(ContactDetailsTab),
            Type = typeof(PropertyString))]
        public virtual string CompanyStreetAddress { get; set; }

        /// <summary>
        /// Gets or sets the company postal address, such as a PO box
        /// </summary>
        /// <remarks>Sort order: 350</remarks>
        [PageTypeProperty(
            EditCaption = "Our postal address",
            HelpText = "Our own postal address, commonly a PO box",
            DisplayInEditMode = true,
            Required = false,
            Searchable = false,
            UniqueValuePerLanguage = true,
            SortOrder = 350,
            Tab = typeof(ContactDetailsTab),
            Type = typeof(PropertyString))]
        public virtual string CompanyPostalAddress { get; set; }

        /// <summary>
        /// Gets or sets the company zip code
        /// </summary>
        /// <remarks>Sort order: 500</remarks>
        [PageTypeProperty(
            EditCaption = "Our zip code",
            HelpText = "Our own zip code, commonly displayed in headers or on contact pages",
            DisplayInEditMode = true,
            Required = false,
            Searchable = false,
            UniqueValuePerLanguage = true,
            SortOrder = 500,
            Tab = typeof(ContactDetailsTab),
            Type = typeof(PropertyString))]
        public virtual string CompanyZipCode { get; set; }

        /// <summary>
        /// Gets or sets the company city
        /// </summary>
        /// <remarks>Sort order: 600</remarks>
        [PageTypeProperty(
            EditCaption = "Our city",
            HelpText = "Our own city or postal area, commonly displayed in headers or on contact pages",
            DisplayInEditMode = true,
            Required = false,
            Searchable = false,
            UniqueValuePerLanguage = true,
            SortOrder = 600,
            Tab = typeof(ContactDetailsTab),
            Type = typeof(PropertyString))]
        public virtual string CompanyCity { get; set; }

        /// <summary>
        /// Gets or sets the company e-mail address
        /// </summary>
        /// <remarks>Sort order: 200</remarks>
        [PageTypeProperty(
            EditCaption = "Our e-mail address",
            HelpText = "Our own e-mail address, commonly displayed in headers or on contact pages",
            DisplayInEditMode = true,
            Required = false,
            Searchable = false,
            UniqueValuePerLanguage = false,
            SortOrder = 200,
            Tab = typeof(ContactDetailsTab),
            Type = typeof(PropertyString))]
        public virtual string CompanyEmail { get; set; }

        #endregion

        #region Site settings

        /// <summary>
        /// Gets or sets the container page for articles
        /// </summary>
        /// <remarks>Sort order: 100</remarks>
        [PageTypeProperty(
            EditCaption = "News container",
            HelpText = "Start page for news or blog posts",
            DisplayInEditMode = true,
            Required = false,
            Searchable = false,
            UniqueValuePerLanguage = false,
            SortOrder = 100,
            Tab = typeof (SiteSettingsTab),
            Type = typeof (PropertyPageReference))]
        public virtual PageReference NewsContainer { get; set; }

        /// <summary>
        /// Gets or sets the container page for contacts
        /// </summary>
        /// <remarks>Sort order: 100</remarks>
        [PageTypeProperty(
            EditCaption = "Contacts container",
            HelpText = "Container page for contact pages",
            DisplayInEditMode = true,
            Required = false,
            Searchable = false,
            UniqueValuePerLanguage = false,
            SortOrder = 100,
            Tab = typeof(SiteSettingsTab),
            Type = typeof(PropertyPageReference))]
        public virtual PageReference ContactsContainer { get; set; }

        /// <summary>
        /// Gets or sets the container page for tag pages
        /// </summary>
        /// <remarks>Sort order: 200</remarks>
        [PageTypeProperty(
            EditCaption = "Tags container",
            HelpText = "Container for tag pages",
            DisplayInEditMode = true,
            Required = false,
            Searchable = false,
            UniqueValuePerLanguage = false,
            Tab = typeof (SiteSettingsTab),
            SortOrder = 200,
            Type = typeof (PropertyPageReference))]
        public virtual PageReference TagsContainer { get; set; }

        /// <summary>
        /// Gets or sets the page type used for date folders
        /// </summary>
        /// <remarks>Sort order: 300</remarks>
        [PageTypeProperty(
            EditCaption = "Date folder type",
            HelpText = "Page type to use for date folder structures",
            DisplayInEditMode = true,
            Required = false,
            Searchable = false,
            UniqueValuePerLanguage = false,
            SortOrder = 300,
            Tab = typeof (SiteSettingsTab),
            Type = typeof (PropertyPageType))]
        public virtual int? DateFolderPageTypeId { get; set; }

        /// <summary>
        /// Gets or sets the page type used to create tag pages
        /// </summary>
        /// <remarks>Sort order: 400</remarks>
        [PageTypeProperty(
            EditCaption = "Tag page type",
            HelpText = "Page type to use for tag pages",
            DisplayInEditMode = true,
            Required = false,
            Searchable = false,
            UniqueValuePerLanguage = false,
            SortOrder = 400,
            Tab = typeof (SiteSettingsTab),
            Type = typeof (PropertyPageType))]
        public virtual int? TagPageTypeId { get; set; }

        /// <summary>
        /// Gets or sets the page type used for articles and blog posts
        /// </summary>
        /// <remarks>Sort order: 500</remarks>
        [PageTypeProperty(
            EditCaption = "Article page type",
            HelpText = "The page type to use when publishing posts through the MetaWeblog API, for example using Microsoft Live Writer",
            DisplayInEditMode = true,
            Required = false,
            Searchable = false,
            UniqueValuePerLanguage = false,
            SortOrder = 500,
            Tab = typeof (SiteSettingsTab),
            Type = typeof (PropertyPageType))]
        public virtual int? ArticlePageTypeId { get; set; }

        /// <summary>
        /// Gets or sets the page type used for standard pages
        /// </summary>
        /// <remarks>Sort order: 600</remarks>
        [PageTypeProperty(
            EditCaption = "Standard page type",
            HelpText = "The page type to use when publishing pages through the MetaWeblog API, for example using Microsoft Live Writer",
            DisplayInEditMode = true,
            Required = false,
            Searchable = false,
            UniqueValuePerLanguage = false,
            SortOrder = 600,
            Tab = typeof (SiteSettingsTab),
            Type = typeof (PropertyPageType))]
        public virtual int? StandardPageTypeId { get; set; }

        /// <summary>
        /// Gets or sets the page type used for person-type contact pages
        /// </summary>
        /// <remarks>Sort order: 700</remarks>
        [PageTypeProperty(
            EditCaption = "Person page type",
            HelpText = "Page type used for contact persons, authors and similar purposes",
            DisplayInEditMode = true,
            Required = false,
            Searchable = false,
            UniqueValuePerLanguage = false,
            SortOrder = 700,
            Tab = typeof (SiteSettingsTab),
            Type = typeof (PropertyPageType))]
        public virtual int? PersonPageTypeId { get; set; }

        /// <summary>
        /// The language used when publishing pages through MetaWeblog
        /// </summary>
        /// <remarks>Sort order: 800</remarks>
        [PageTypeProperty(
            EditCaption = "MetaWeblog content language",
            HelpText = "Language to use when publishing content through the MetaWeblog API",
            DisplayInEditMode = true,
            Required = false,
            Searchable = false,
            UniqueValuePerLanguage = false,
            SortOrder = 800,
            Tab = typeof (SiteSettingsTab),
            Type = typeof (PropertyLanguage))]
        public virtual string MetaWeblogPublishLanguage { get; set; }

        /// <summary>
        /// Gets or sets if automatic date folder sorting under the news container should be disabled
        /// </summary>
        /// <remarks>Sort order: 1000</remarks>
        [PageTypeProperty(
            EditCaption = "Disable date folder sorting",
            HelpText = "Disables date folder sorting for articles created under the news container",
            DisplayInEditMode = true,
            Required = false,
            Searchable = false,
            UniqueValuePerLanguage = false,
            SortOrder = 1000,
            Tab = typeof(SiteSettingsTab),
            Type = typeof(PropertyBoolean))]
        public virtual bool DisableDateFolderSorting { get; set; }

        /// <summary>
        /// Gets or sets folder where static files are stored
        /// </summary>
        /// <remarks>Sort order: 1090. Stylesheets will be linked from subfolder called 'css', scripts will be linked from subfolder called 'scripts'.</remarks>
        [PageTypeProperty(
            EditCaption = "Static files path",
            HelpText = "Virtual path to static files folder for stylesheets, scripts and graphics",
            DefaultValueType = DefaultValueType.Value,
            DefaultValue = "/Templates/",
            DisplayInEditMode = true,
            Required = false,
            Searchable = false,
            UniqueValuePerLanguage = false,
            SortOrder = 1090,
            Tab = typeof(SiteSettingsTab),
            Type = typeof(PropertyString))]
        public virtual string StaticFilesPath { get; set; }

        /// <summary>
        /// Gets or sets if stylesheet rendering should be disabled
        /// </summary>
        /// <remarks>Sort order: 1100</remarks>
        [PageTypeProperty(
            EditCaption = "Disable stylesheet links",
            HelpText = "Prevent EPiServer Template Foundation from adding automatic stylesheet links",
            DisplayInEditMode = true,
            Required = false,
            Searchable = false,
            UniqueValuePerLanguage = false,
            SortOrder = 1100,
            Tab = typeof(SiteSettingsTab),
            Type = typeof(PropertyBoolean))]
        public virtual bool DisableStylesheetLinks { get; set; }

        /// <summary>
        /// Gets or sets if JavaScript links rendering should be disabled
        /// </summary>
        /// <remarks>Sort order: 1200</remarks>
        [PageTypeProperty(
            EditCaption = "Disable JavaScript links",
            HelpText = "Prevent EPiServer Template Foundation from adding automatic JavaScript links",
            DisplayInEditMode = true,
            Required = false,
            Searchable = false,
            UniqueValuePerLanguage = false,
            SortOrder = 1200,
            Tab = typeof(SiteSettingsTab),
            Type = typeof(PropertyBoolean))]
        public virtual bool DisableJavaScriptLinks { get; set; }

        #endregion
    }
}